<!DOCTYPE html>
<html>
<head>
    <title>Using Ajax to submit data</title>

    <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>

    <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
</head>
<body>

<form class="registerForm">
    <div class="form-group">
        <input type="text" class="form-control" name="username" placeholder="Username" />
    </div>
    <div class="form-group">
        <input type="text" class="form-control" name="email" placeholder="Email address" />
    </div>
     <div class="form-group">
        <div class="col-lg-9 col-lg-offset-3">
            <button type="submit" class="btn btn-primary">Sign up</button>
        </div>
      </div>
</form>
<script>
$(document).ready(function() {
    $('.registerForm').bootstrapValidator({
    	excluded: [':disabled', ':hidden', ':not(:visible)'],//排除，不包括在内
        message: 'This value is not valid',
        //live: 'enabled',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',//有效
            invalid: 'glyphicon glyphicon-remove',//无效
            validating: 'glyphicon glyphicon-refresh'//验证
        },
        fields: {									//领域
            username: {
                message: 'The username is not valid',   //消息
                validators: {							//验证器
                    notEmpty: {
                        message: 'The username is required and cannot be empty'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    },
                    regexp: {							//正则验证
                        regexp: /^[a-zA-Z0-9_]+$/,
                        message: 'The username can only consist of alphabetical, number and underscore'
                    }
                }
            },
            email: {
                validators: {
                    notEmpty: {
                        message: 'The email is required and cannot be empty'
                    },
                    emailAddress: {
                        message: 'The input is not a valid email address'
                    }
                }
            }
        }
    });
});
</script>
</body>
</html>